package aom.ju.ss.view.user.shop.management

import aom.ju.ss.R
import aom.ju.ss.databinding.ShopMangerActivityBinding
import aom.ju.ss.mode.ShopShopInfoMode
import aom.ju.ss.utils.http.LP_API.shop_info
import aom.ju.ss.utils.http.LP_API.shop_order_order_list
import aom.ju.ss.utils.http.OKHttpUtils
import aom.ju.ss.utils.show
import aom.ju.ss.utils.start
import aom.ju.ss.view.base.BaseActivity
import aom.ju.ss.view.user.shop.management.goods.GoodsManage
import aom.ju.ss.view.user.shop.management.order.OrderManage
import com.google.gson.Gson

/**
 * 商家管理
 */
class ShopMangerActivity : BaseActivity() {
    private lateinit var binding: ShopMangerActivityBinding
    override fun init() {
        OKHttpUtils(activity)
            .SetApiUrl(shop_info)
            .POST(this)
        binding = viewBinding as ShopMangerActivityBinding
        binding.fahuo.setOnClickListener { start(OrderManage::class.java, "3") }// 待收货
        binding.huifu.setOnClickListener { }
        binding.order.setOnClickListener { start(OrderManage::class.java) }
        binding.goods.setOnClickListener { start(GoodsManage::class.java) }
        binding.shopGet.setOnClickListener { }
        binding.qiangquan.setOnClickListener { }
        binding.zhubo.setOnClickListener { }

        OKHttpUtils(activity,false)
            .SetApiUrl(shop_order_order_list)
            .SetKey("type", "status", "page")
            .SetValue("0", "3", "1")
            .POST(this)

    }

    override fun ok(jsonString: String, httpTY: String) {
        super.ok(jsonString, httpTY)
        if (httpTY == shop_info) {
            val mode = Gson().fromJson(jsonString, ShopShopInfoMode::class.java)
            binding.info = mode.data

            binding.shopManagement.setOnClickListener {
                start(
                    ShopMangerChildActivity::class.java,
                    Gson().toJson(mode.data)
                )
            }
        }
    }

    override fun error(e: String, jsonString: String, httpTY: String) {
        super.error(e, jsonString, httpTY)
        e.show
    }

    override val lay: Int = R.layout.shop_manger_activity

}